package com.x.controller;

import com.x.entity.po.AddBlogPO;
import com.x.entity.po.UpdBlogPO;
import com.x.result.Result;
import com.x.service.BlogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

/**
 * @description
 * @Author Lin
 * @Date 2021/5/21 16:29
 */
@Api("博客")
@CrossOrigin
@RestController
@RequestMapping("/blog")
public class BlogController {

    @Autowired
    BlogService blogService;

    @ApiOperation("发布博客")
    @PostMapping("/insertBlog")
    public Result insertBlog(@RequestBody AddBlogPO addBlogPO){
        return blogService.insertBlog(addBlogPO);
    }

    @ApiOperation("批量删除博客")
    @PostMapping("/deleteBlog")
    public Result deleteBlog(@RequestParam("ids") ArrayList<Integer> ids){
        return blogService.deleteBlog(ids);
    }

    @ApiOperation("修改博客")
    @PostMapping("/updateBlog")
    public Result updateBlog(@RequestBody UpdBlogPO updBlogPO){
        return blogService.updateBlog(updBlogPO);
    }

    @ApiOperation("分页查询所有博客")
    @GetMapping("/listBlog")
    public Result listBlog(@RequestParam("pageNo") int pageNo, @RequestParam("pageSize") int pageSize){
        return blogService.listBlog(pageNo, pageSize);
    }
}









